<?php
if(!defined('IN_PHPSCUP'))exit('hacking'); 
class NewApp extends BaseApp
{

    var $type = 'new';
	
    function index()
    {
		if(!isset($_POST['word']))
		{
		$_POST['word'] = '';
		}
		if(!isset($_GET['cat']))
		{
		$_GET['cat'] = '';
		}
		if(!isset($_GET['v']))
		{
		$_GET['v'] = '';
		}				
	    $word = $_POST['word'];
		$word_array = explode(' ',$word);
		
		foreach($word_array as $key => $value)
		{
			if(!$value)
			{
             unset($word_array[$key]);
		    }  
		}
		
		$cat = intval($_GET['cat']);
				 
        $order = '';
		$v = $_GET['v'];
		
		if($v == 'timeasc')
		{
        $order = 'A.add_time asc';
		}
		else if($v == 'timedesc')
		{
        $order = 'A.add_time desc';		
		}
		else if($v == 'showyes')
		{
        $order = 'A.is_show desc';		
		}
		else if($v == 'showno')
		{
        $order = 'A.is_show asc';		
		}
		else if($v == 'topyes')
		{
        $order = 'A.is_top desc';		
		}
		else if($v == 'topno')
		{
        $order = 'A.is_top asc';		
		}
		else if($v == 'recyes')
		{
        $order = 'A.is_recommend desc';		
		}
		else if($v == 'recno')
		{
        $order = 'A.is_recommend asc';		
		}
		else if($v == 'indexyes')
		{
        $order = 'A.is_index desc';		
		}
		else if($v == 'indexno')
		{
        $order = 'A.is_index asc';		
		}
		$GLOBALS['Lang']->_get_lang('new');					
		$TB_nav = &$this->_model('nav');	 
		
		$navdata = $TB_nav->show(COMPANY_ID);
	
		foreach($navdata as $key => $value)
		{
		 unset($navdata[$key]['config']);				
         $navdata[$key]['config'] = @unserialize($value['config']);		
		}			
	
        $this->assign('navigation', $navdata);
		$companydata = $TB_nav->companymsg(COMPANY_ID);			
        $this->assign('companydata', $companydata);			
        $pic_data = include(ROOT_PATH . '/data/cache/rollpic_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('pic_data', $pic_data);		
        $qq_data = array();
        $qq_temp1 = del_empty_var(explode('|', QQ_SET_DATA));
		foreach($qq_temp1 as $key=>$value)
		{
           $qq_temp2 = del_empty_var(explode(':', $value));	
		   $qq_data[$qq_temp2[0]] = $qq_temp2[1];     
		}
        $this->assign('qq_data',$qq_data);		
	
		$TB_new = &$this->_model('new');
		$index_data = $TB_new->isindex(COMPANY_ID);
        $this->assign('index_data', $index_data);
        $this->assign('cat', $cat);							
		$data = $TB_new->show($order,$v,$word_array,$cat,COMPANY_ID);	
			
        $this->assign('lw_data', $data['data']);		
		$this->assign('lw_page', $data['page']);	
        $this->assign('companyid',COMPANY_ID);						
	    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', SITE_TITLE);
        $this->assign('page_description', SITE_DESCRIPTION);
        $this->assign('page_keywords', SITE_KEYWORDS);		
        $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));

        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);
						$this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');
	        $this->assign('site_url',SITE_URL);	
        $this->display('new.view.html');
    }


    function show()
    {
		if(!isset($_GET['cat']))
		{
		$_GET['cat'] = '';
		}
				$cat = intval($_GET['cat']);		
		$id= intval($_GET['id']);
		$GLOBALS['Lang']->_get_lang('new');	
		$TB_nav = &$this->_model('nav');	 
		
		$navdata = $TB_nav->show(COMPANY_ID);
		foreach($navdata as $key => $value)
		{
		 unset($navdata[$key]['config']);				
         $navdata[$key]['config'] = @unserialize($value['config']);		
		}			
		
        $this->assign('navigation', $navdata);
		$companydata = $TB_nav->companymsg(COMPANY_ID);			
        $this->assign('companydata', $companydata);			
		
        $qq_data = array();
        $qq_temp1 = del_empty_var(explode('|', QQ_SET_DATA));
		foreach($qq_temp1 as $key=>$value)
		{
           $qq_temp2 = del_empty_var(explode(':', $value));	
		   $qq_data[$qq_temp2[0]] = $qq_temp2[1];     
		}
        $this->assign('qq_data',$qq_data);			
		$TB_new = &$this->_model('new');
				
		$data = $TB_new->oneshow($id,COMPANY_ID);		
		$TB_new->vistnumadd($id);	
		

        $this->assign('cat', $cat);			
        $this->assign('companyid',COMPANY_ID);	
        $this->assign('data', $data);	
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', SITE_TITLE.'-'.$data['title']);
        $this->assign('page_description', SITE_DESCRIPTION.'-'.$data['description']);
        $this->assign('page_keywords', SITE_KEYWORDS.'-'.$data['keywords']);		
		$this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);	        $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
	        $this->assign('site_url',SITE_URL);
		
        $this->display('newshow.view.html');
    }


   
}






?>